//
//  UIImage+AYMExtension.m
//  QuickCure
//
//  Created by guo3920591 on 16/5/9.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "UIImage+AYMExtension.h"

@implementation UIImage (AYMExtension)

-(UIImage *)scaleToWidth:(CGFloat)width{
    
    if (self.size.width<width) {
        return self;
    }
   
    CGFloat height = width/self.size.width*self.size.height;
    
    CGRect rect = CGRectMake(0, 0, width, height);
    
    UIGraphicsBeginImageContext(rect.size);
    
    [self drawInRect:rect];
    
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return img;
    
}
@end
